#include<iostream>

const int size=100;

int main()
{
    FILE* fp=popen("ls -al","r");
    if(fp==nullptr)
    {
        std::cout<<"open error"<<std::endl;
    }
    else
        std::cout<<"popen succeed"<<std::endl;

    char buffer[size];

    while(fgets(buffer,size,fp)!=nullptr)
    {
        printf("%s",buffer);
    }

    pclose(fp);
    return 0;
}
